package com.yoso.shop.infrastructure.base.controller;

import com.yoso.shop.infrastructure.base.entity.BaseEntity;
import com.yoso.shop.infrastructure.base.service.BaseEntityExample;
import com.yoso.shop.infrastructure.base.service.IBaseService;
import com.yoso.shop.infrastructure.base.vo.BaseVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Lenovo
 */
public abstract class AbstractBaseController<V extends BaseVo,E extends BaseEntity> extends AbstractController{

    public abstract E V2E(V data);
    public abstract V E2V(E data);

    public List<E> bachV2E(List<V> vs){
        List<E> result = new ArrayList<>();
        vs.forEach(e->{
            result.add(V2E(e));
        });
        return result;
    }
    public List<V> bachE2V(List<E> es){
        List<V> result = new ArrayList<>();
        es.forEach(e->{
            result.add(E2V(e));
        });
        return result;
    }
    public abstract <M extends BaseEntityExample> IBaseService<E,M> getService();
}
